<script>
import { getCompanyInfoAPI } from '@/api/settingsApi'
import { mapState } from 'vuex'

export default {
  name: 'companyInfo',
  data() {
    return {
      title: '对公司名称、公司地址、营业执照、公司地区的更新，将使得公司资料被重新审核，请谨慎修改'
    }
  },
  methods: {
    /* 派发action发送请求获取企业信息的回调函数 */
    async fetchCompanyInfo() {
      try {
        await this.$store.dispatch('settingsStore/fetchCompanyInfo', this.userInfo.companyId)
      } catch (error) {
        this.$message.error(error.message)
      }
    }
  },
  computed: {
    ...mapState('userStore', ['userInfo']),
    ...mapState('settingsStore', ['companyInfo'])
  },
  mounted() {
    this.fetchCompanyInfo()
  }
}
</script>

<template>
  <div class="companyInfo">
    <el-alert :title="title" type="info" show-icon :closable="false"></el-alert>
    <el-form label-width="100px">
      <el-form-item label="公司名称">
        <el-input placeholder="请输入公司名称" :disabled="true" v-model="companyInfo.name"></el-input>
      </el-form-item>
      <el-form-item label="公司地址">
        <el-input placeholder="请输入公司地址" :disabled="true" v-model="companyInfo.companyAddress"></el-input>
      </el-form-item>
      <el-form-item label="公司邮箱">
        <el-input placeholder="请输入公司邮箱" :disabled="true" v-model="companyInfo.mailbox"></el-input>
      </el-form-item>
      <el-form-item label="创建时间">
        <el-date-picker v-model="companyInfo.createTime" type="date" placeholder="选择日期" :disabled="true"></el-date-picker>
      </el-form-item>
      <el-form-item label="公司备注">
        <el-input type="textarea" rows="4" :disabled="true" placeholder="请输入公司备注" v-model="companyInfo.remarks"></el-input>
      </el-form-item>
    </el-form>
  </div>
</template>

<style scoped lang="scss">
.companyInfo {
  .el-form {
    width: 35%;
    margin-top: 30px;
    .el-date-editor{
      width: 100%;
    }
  }
}
</style>
